package com.wms.controller;

import com.wms.common.CallBack;
import com.wms.common.Response;
import com.wms.domain.InStoreDetailDomain;
import com.wms.domain.InStoreIdxDomain;
import com.wms.dto.InStoreDetailDto;
import com.wms.service.InStore.InStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "入库管理")
@RequestMapping(path = "/InStore/")
@RestController
public class InStore {
    @Autowired
    private InStoreService inStoreService;

    @ApiOperation(value="新增通知单")
    @RequestMapping(path="addNotice",method= RequestMethod.POST)
    public Response addNotice(@RequestBody InStoreIdxDomain inStoreIdxDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return inStoreService.addNotice(inStoreIdxDomain);
            }
        }.execute();
    }

    @ApiOperation(value="查询通知单")
    @RequestMapping(path="getNoticePage",method= RequestMethod.POST)
    public Response getNoticePage(@RequestBody InStoreIdxDomain inStoreIdxDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return inStoreService.getNoticePage(inStoreIdxDomain);
            }
        }.execute();
    }

    @ApiOperation(value="查询待到货")
    @RequestMapping(path="getArrivedPage",method= RequestMethod.POST)
    public Response getArrivedPage(@RequestBody InStoreDetailDto inStoreDetailDto){
        return new CallBack() {
            @Override
            protected Object run() {
                return inStoreService.getArrivedPage(inStoreDetailDto);
            }
        }.execute();
    }

    @ApiOperation(value="修改通知单")
    @RequestMapping(path="noticeUpdate",method= RequestMethod.POST)
    public Response noticeUpdate(@RequestBody InStoreIdxDomain inStoreIdxDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return inStoreService.noticeUpdate(inStoreIdxDomain);
            }
        }.execute();
    }

    @ApiOperation(value="修改通知单详情")
    @RequestMapping(path="updateNoticeDetail",method= RequestMethod.POST)
    public Response updateNoticeDetail(@RequestBody InStoreDetailDomain inStoreDetailDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return inStoreService.updateDetail(inStoreDetailDomain);
            }
        }.execute();
    }

    @ApiOperation(value="完成入库")
    @RequestMapping(path="inStoreFinish",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "ids", required = true)
    public Response inStoreFinish(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return inStoreService.inStoreFinish(id);
            }
        }.execute();
    }

}
